#ifndef DEVICEUIWIDGET_H
#define DEVICEUIWIDGET_H

#include <QWidget>
#include <QDomNode>

namespace Ui
{
    class DeviceUiWidget;
}

class QTableWidgetItem;
class QTreeWidgetItem;
class QGraphicsScene;
class QGraphicsPixmapItem;
class DeviceUiWidget : public QWidget
{
    Q_OBJECT
public:
    explicit DeviceUiWidget(QWidget *parent = nullptr);
    ~DeviceUiWidget();

    void setDeviceInfo(const QVariantMap &deviceInfo);

protected:
    virtual bool eventFilter(QObject *watched, QEvent *event);
    virtual void resizeEvent(QResizeEvent *event);

private slots:

//    void slotItemClicked(QTreeWidgetItem *item, int column);
//    void slotItemDoubleClicked(QTableWidgetItem *item);

    void on_btn_load_clicked();
    void on_btn_expand_clicked();
    void on_btn_shou_clicked();

    void on_edit_search_textChanged(const QString &arg1);
    void on_table_node_itemDoubleClicked(QTableWidgetItem *item);
    void on_tree_by_itemClicked(QTreeWidgetItem *item, int column);

    void on_btn_open_clicked();

    void on_btn_close_clicked();

private:
    void pictureAdaptiveSize(const QPixmap &pixmap);
    void parseDumpXml(const QString &dumpFile);
    void showXmlTreeNode(QTreeWidgetItem *treeParent, QDomNode domParent);
    void selectItemByPoint(const QPoint &point);
    void painterTextPixmap(QPixmap &pixmap);
    void loadDeviceUi();


private:
    Ui::DeviceUiWidget *ui;

    QGraphicsScene *m_pScene;
    QGraphicsPixmapItem *m_pPixmapItem;
    double m_ratio;

    QString m_deviceId;
};

#endif // DEVICEUIWIDGET_H
